package com.bjesc_b2c.app.appraiset.mvp.view.activity;

import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.bjesc_b2c.app.appraiset.R;
import com.bjesc_b2c.app.appraiset.base.BaseFragmentActivity;
import com.bjesc_b2c.app.appraiset.widget.popupwindow.OrderStatusOperationPop;

import butterknife.ButterKnife;
import butterknife.InjectView;
import butterknife.OnClick;

public class OrderDetailsActivity extends BaseFragmentActivity {

    @InjectView(R.id.iv_return)
    ImageView returnIv;
    @InjectView(R.id.tv_title)
    TextView title;
    @InjectView(R.id.tv_car_type)
    TextView carType;
    @InjectView(R.id.tv_car_num)
    TextView carNum;
    @InjectView(R.id.tv_assessment_time)
    TextView assessmentTime;
    @InjectView(R.id.tv_assessment_address)
    TextView assessmentAddress;
    @InjectView(R.id.tv_car_master)
    TextView carMaster;
    @InjectView(R.id.iv_master_phone)
    ImageView masterPhone;
    @InjectView(R.id.iv_master_msg)
    ImageView masterMsg;
    @InjectView(R.id.tv_appraiser)
    TextView appraiser;
    @InjectView(R.id.rlty_newest_progress)
    RelativeLayout newestProgress;
    @InjectView(R.id.tv_progress_status)
    TextView progressStatus;
    @InjectView(R.id.btn_operate)
    Button operate;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_customer_details);
        ButterKnife.inject(this);
        title.setText("客户详情");
    }

    @OnClick({R.id.tv_add_time, R.id.tv_look_info, R.id.iv_return, R.id.iv_master_phone,
            R.id.tv_master_msg,R.id.tv_customer_track,R.id.tv_demand_car,R.id.btn_move_order})
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.btn_operate:  //操作
                OrderStatusOperationPop pop = new OrderStatusOperationPop(OrderDetailsActivity.this, null);
                pop.showAtView(operate);
                break;
            case R.id.btn_move_order: //开始评估

                break;
            case R.id.iv_master_phone: //打电话
                call("13982110343");
                break;
            case R.id.iv_master_msg: //发短信
                sendto("13982110343");
                break;
            case R.id.iv_return:
                finish();
                break;
        }
    }

    /**
     * 调用拨号功能
     *
     * @param phone 电话号码
     */
    private void call(String phone) {
        Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:" + phone));
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        startIntent(intent, false);
    }

    private void sendto(String phone) {
        Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.parse("smsto:" + phone));
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        startIntent(intent, false);
    }
}